﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LeetCodeSolutions
{
    /// <summary>
    /// 1523. 在区间范围内统计奇数数目
    /// </summary>
    class LeetCode1523: LeetCodeBase
    {
        public override void Execute()
        {
            throw new NotImplementedException();
        }

        public int CountOdds(int low, int high)
        {
            int count = 0;
            if (low % 2 == 1)
            {
                for (int i = low; i <= high; i += 2)
                {
                    if (i % 2 == 1)
                    {
                        count++;
                    }
                }
            }
            else
            {
                for (int i = low + 1; i <= high; i += 2)
                {
                    if (i % 2 == 1)
                    {
                        count++;
                    }
                }
            }

            return count;
        }
    }
}
